﻿package com.wandian.view.mediator
{
	import com.greensock.TweenLite;
	import com.wandian.controller.*;
	import com.wandian.data.GameData;
	import com.wandian.model.*;
	import com.wandian.model.vo.*;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.mediator.*;

	/**   
	 * 控制照明灯显示隐藏
	 * @author long
	 * @QQ 108232706
	 * @version 1.0   
	 */ 
	public class IlluminationMediator extends Mediator
	{
		private var _arrLight:Array;
		public static const NAME:String="IlluminationMediator";

		public function IlluminationMediator(param1:Object)
		{
			super(NAME, param1);
			this.init();
			return;
		} 

		override public function listNotificationInterests():Array
		{
			return [CLZNoticeName.OPERATION_PALYER, CLZNoticeName.OPERATION_SUCC,CLZNoticeName.GAME_OVER];
		} 

		override public function handleNotification(notification:INotification):void
		{
			var data:Object=notification.getBody();
			var seatId:int=0;
			switch (notification.getName())
			{
				case CLZNoticeName.OPERATION_PALYER:
				{
					seatId=data.seatId;
					this.showSit(seatId);
					break;
				}
				case CLZNoticeName.OPERATION_SUCC:
				{
					this.hideSit();
					break;
				}
				case CLZNoticeName.GAME_OVER:
				{
					this.hideSit();
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		} 

		private function init():void
		{
			this._arrLight=[this.mcPanel.light1, this.mcPanel.light2, this.mcPanel.light3, this.mcPanel.light4, this.mcPanel.light5, this.mcPanel.light6, this.mcPanel.light7, this.mcPanel.light8, this.mcPanel.light9];
			var _loc_1:int=0;
			while (_loc_1 < this._arrLight.length)
			{

				this._arrLight[_loc_1].visible=false;
				_loc_1=_loc_1 + 1;
			}
			this.mcPanel.light_mc.visible=false;
			return;
		} 

		public function showSit(seatId:int):void
		{
			this.mcPanel.light_mc.visible=true;
			var pointMc:*=this._arrLight[(seatId - 1)];
			TweenLite.to(this.mcPanel.light_mc, 0.5, {x: pointMc.x, y: pointMc.y, scaleX: pointMc.scaleX, scaleY: pointMc.scaleY, rotation: pointMc.rotation});
			return;
		} 

		/**
		 * 隐藏闪光灯
		 */
		public function hideSit():void
		{
			this.mcPanel.light_mc.visible=false;
			return;
		} 

		private function get mcPanel():MovieClip
		{
			return viewComponent as MovieClip;
		} 

	}
}
